package org.jeecg.modules.sxaq;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.sxaq.ior.service.IRecordInoutService;
import org.jeecg.modules.sxaq.ior.service.impl.RecordInoutServiceImpl;
import org.jeecg.modules.sxaq.qrcode.controller.QRCodeController;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sys/test")
public class TestController {

    @Autowired
    private IRecordInoutService recordInoutService;

    @Autowired
    private ISysUserService sysUserService;

    @RequestMapping(value = "/inout", method = RequestMethod.POST)
    @ApiOperation("获取扫码枪返回的数据")
    public void getCodeScanningGunResult(@RequestBody JSONObject object) throws Exception {
        List<SysUser> sysUsers = sysUserService.getAllUser();
        for (int i = 0; i < sysUsers.size(); i++) {
            if (i < 1000) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("type", object.getIntValue("type") + "");
                jsonObject.put("password", "1234");
                jsonObject.put("factoryCode", "F01");
                jsonObject.put("workNo", sysUsers.get(i).getWorkNo());
                jsonObject.put("phone", sysUsers.get(i).getPhone());
                jsonObject.put("mobileSingle", "3fdcafb5e43443da");
                recordInoutService.entranceAndExit1(jsonObject);
            }
        }
    }

}
